.bx-settings-dialog {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    opacity: 0.98;
    user-select: none;
    -webkit-user-select: none;

    .bx-settings-reload-note {
        font-size: 0.8rem;
        display: block;
        padding: 8px;
        font-style: italic;
        font-weight: normal;
        height: var(--bx-button-height);
    }
}

.bx-settings-tabs-container {
    position: fixed;
    width: 48px;
    max-height: 100vh;
    display: flex;
    flex-direction: column;

    > div:last-of-type {
        display: flex;
        flex-direction: column;
        align-items: end;

        button {
            flex-shrink: 0;
            border-top-right-radius: 0;
            border-bottom-right-radius: 0;
            margin-top: 8px;
            height: unset;
            padding: 8px 10px;

            svg {
                size = 16px;

                width: size;
                height: size;
            }
        }
    }
}

.bx-settings-tabs {
    display: flex;
    flex-direction: column;
    border-radius: 0 0 0 8px;
    box-shadow: 0 0 6px #000;
    overflow: overlay;
    flex: 1;

    svg {
        size = 24px;
        width: size;
        height: size;
        padding: 10px;
        flex-shrink: 0;
        box-sizing: content-box;
        background: #131313;
        cursor: pointer;
        border-left: 4px solid #1e1e1e;

        &.bx-active {
            background: #222;
            border-color: #008746;
        }

        &:not(.bx-active):hover {
            background: #2f2f2f;
            border-color: #484848;
        }

        &:focus {
            border-color: #fff;
        }

        &[data-group=global] {
            &[data-need-refresh=true] {
                background: var(--bx-danger-button-color) !important;

                &:hover {
                    background: var(--bx-danger-button-hover-color) !important;
                }
            }
        }
    }
}


.bx-settings-tab-contents {
    tabsWidth = 48px;

    flex-direction: column;
    margin-left: tabsWidth;
    width: 450px;
    background: #1a1b1e;
    color: #fff;
    font-weight: 400;
    font-size: 16px;
    font-family: var(--bx-title-font);
    text-align: center;
    box-shadow: 0px 0px 6px #000;
    overflow: overlay;
    z-index: 1;

    .bx-top-buttons {
        display: flex;
        flex-direction: column;
        gap: 8px;
        margin-bottom: 8px;

        .bx-button {
            display: block;
        }
    }

    h2 {
        margin: 16px 0 8px 0;
        display: flex;
        align-items: center;

        &:first-of-type {
            margin-top: 0;
        }

        span {
            display: inline-block;
            font-size: 20px;
            font-weight: bold;
            text-align: left;
            flex: 1;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
            min-height: var(--bx-button-height);
            align-content: center;
        }
    }
}

@media (max-width: 500px) {
    .bx-settings-tab-contents {
        width: calc(100vw - 48px);
    }
}

.bx-settings-row {
    display: flex;
    gap: 10px;
    padding: 16px 10px;
    background: #2a2a2a;
    border-bottom: 1px solid #343434;

    &:hover, &:focus-within {
        background-color: #242424;
    }

    &:not(:has(> input[type=checkbox])) {
        flex-wrap: wrap;
    }

    /*
    &:has(input:focus), &:has(select:focus), &:has(button:focus) {
        border-left-color: white;
    }
    */

    > span.bx-settings-label {
        font-size: 14px;
        display: block;
        text-align: left;
        align-self: center;
        margin-bottom: 0 !important;
        flex: 1;

        svg {
            width: 20px;
            height: 20px;
            margin-inline-end: 8px;
        }

        + * {
            margin: 0 0 0 auto;
        }
    }

    &[data-multi-lines="true"] {
        flex-direction: column;

        > span.bx-settings-label {
            align-self: start;

            + * {
                margin: unset;
            }
        }
    }

    &.bx-settings-important-row {
        background: #733b00;
    }
}

.bx-settings-dialog-note {
    display: block;
    color: #afafb0;
    font-size: 12px;
    font-weight: lighter;
    font-style: italic;

    &:not(:has(a)) {
        margin-top: 4px;
    }

    a {
        display: inline-block;
        padding: 4px;
    }
}

.bx-settings-custom-user-agent {
    display: block;
    width: 100%;
    padding: 6px;
}

.bx-donation-link {
    display: block;
    text-align: center;
    text-decoration: none;
    height: 20px;
    line-height: 20px;
    font-size: 14px;
    margin-top: 10px;
    margin-bottom: 10px;
}

.bx-debug-info {
    button {
        margin-top: 10px;
    }

    pre {
        margin-top: 10px;
        cursor: copy;
        color: white;
        padding: 8px;
        border: 1px solid #2d2d2d;
        background: #212121;
        white-space: break-spaces;
        text-align: left;

        &:hover {
            background: #272727;
        }
    }
}

.bx-settings-app-version {
    margin-top: 10px;
    text-align: center;
    color: #747474;
    font-size: 12px;
}

.bx-note-unsupported {
    display: block;
    font-size: 12px;
    font-style: italic;
    font-weight: normal;
    color: #828282;
}

.bx-settings-tab-content {
    padding: 10px;
    border-radius-size = 6px;

    > div {
        // Label at the beginning
        *:not(.bx-settings-row):has(+ .bx-settings-row) + .bx-settings-row:has(+ .bx-settings-row) {
            border-top-left-radius: border-radius-size;
            border-top-right-radius: border-radius-size;
        }

        // Label at the end
        .bx-settings-row:not(:has(+ .bx-settings-row)) {
            border: none;
            border-bottom-left-radius: border-radius-size;
            border-bottom-right-radius: border-radius-size;
        }

        // Single label
        *:not(.bx-settings-row):has(+ .bx-settings-row) + .bx-settings-row:not(:has(+ .bx-settings-row)) {
            border: none;
            border-radius: border-radius-size;
        }
    }

    &:not([data-game-id="-1"]) {
        .bx-settings-row[data-override=true], .bx-settings-row:has(*[data-override=true]) {
            border-left: 4px solid orange !important;
            border-top-left-radius: 0 !important;
            border-bottom-left-radius: 0 !important;
            padding-left: 6px !important;
        }
    }
}

.bx-suggest-toggler {
    text-align: left;
    display: flex;
    border-radius: 4px;
    overflow: hidden;
    background: #003861;
    height: 45px;
    align-items: center;

    label {
        flex: 1;
        align-content: center;
        padding: 0 10px;
        background: #004f87;
        height: 100%;
    }

    span {
        display: inline-block;
        align-self: center;
        padding: 10px;
        width: 45px;
        text-align: center;
    }

    &:hover, &:focus {
        cursor: pointer;
        background: #005da1;

        label {
            background: #006fbe;
        }
    }

    &[bx-open] {
        span {
            transform: rotate(90deg);
        }

        &+ .bx-suggest-box {
            display: block;
        }
    }
}

.bx-suggest-box {
    display: none;
}

.bx-suggest-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px;
}

.bx-suggest-note {
    font-size: 11px;
    color: #8c8c8c;
    font-style: italic;
    font-weight: 100;
}

.bx-suggest-link {
    font-size: 14px;
    display: inline-block;
    margin-top: 4px;
    padding: 4px;
}

.bx-suggest-row {
    display: flex;
    flex-direction: row;
    gap: 10px;

    label {
        flex: 1;
        overflow: overlay;
        border-radius: 4px;

        .bx-suggest-label {
            background: #323232;
            padding: 4px 10px;
            font-size: 12px;
            text-align: left;
        }

        .bx-suggest-value {
            padding: 6px;
            font-size: 14px;

            &.bx-suggest-change {
                background-color: var(--bx-warning-color);
            }
        }
    }

    &.bx-suggest-ok {
        input {
            visibility: hidden;
        }

        .bx-suggest-label {
            background-color: #008114;
        }

        .bx-suggest-value {
            background-color: #13a72a;
        }
    }

    &.bx-suggest-change {
        .bx-suggest-label {
            background-color: #a65e08;
        }

        .bx-suggest-value {
            background-color: #d57f18;
        }

        &:hover {
            label {
                cursor: pointer;
            }

            .bx-suggest-label {
                background-color: #995707;
            }

            .bx-suggest-value {
                background-color: #bd7115;
            }
        }

        // Unchecked setting
        input:not(:checked) + label {
            opacity: 0.5;

            .bx-suggest-label {
                background-color: #2a2a2a;
            }

            .bx-suggest-value {
                background-color: #393939;
            }
        }

        &:hover {
            input:not(:checked) + label {
                opacity: 1;

                .bx-suggest-label {
                    background-color: #202020;
                }

                .bx-suggest-value {
                    background-color: #303030;
                }
            }
        }
    }
}

.bx-sub-content-box {
    background: #161616;
    padding: 10px;
    box-shadow: 0px 0px 12px #0f0f0f inset;
    border-radius: 10px;

    .bx-settings-row & {
        background: #202020;
        padding: 12px;
        box-shadow: 0 0 4px #000000 inset;
        border-radius: 6px;
    }
}

.bx-controller-extra-settings {
    &[data-has-gamepad=true] {
        > :first-child {
            display: none;
        }

        > :last-child {
            display: block;
        }
    }

    &[data-has-gamepad=false] {
        > :first-child {
            display: block;
        }

        > :last-child {
            display: none;
        }
    }

    .bx-controller-extra-wrapper {
        flex: 1;
        min-width: 1px;
    }

    .bx-sub-content-box {
        flex: 1;
        text-align: left;
        display: flex;
        flex-direction: column;
        margin-top: 10px;

        > label {
            font-size: 14px;
        }
    }
}

.bx-preset-row {
    display: flex;
    gap: 8px;

    .bx-select {
        flex: 1;
    }
}

.bx-stream-settings-selection {
    margin-bottom: 8px;
    position: sticky;
    z-index: 1000;
    top: 0;

    > div {
        display: flex;
        gap: 8px;
        background: #222222;
        padding: 10px;
        border-bottom: 4px solid #353638;
        box-shadow: 0 0 6px #000;
        position: relative;
        z-index: 1;

        .bx-select {
            flex: 1;

            label {
                font-weight: bold;
                font-size: 1.1rem;
                line-height: initial;

                span {
                    line-height: initial;
                }
            }

            .bx-select-indicators {
                display: none;
            }
        }
    }

    p {
        font-family: var(--bx-promptfont-font), var(--bx-normal-font);
        margin: 0;
        font-size: 13px;
        background: #505050f2;
        height: 25px;
        line-height: 23px;
        position: absolute;
        bottom: -25px;
        left: 0;
        right: 0;
        text-shadow: 0 1px #000;
    }
}
